import { ActivatedRoute, Router } from '@angular/router';
import { ChangeDetectorRef, Component, OnInit } from '@angular/core';
import { NzMessageService } from 'ng-zorro-antd/message';

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.less']
})
export class AppComponent implements OnInit{

  constructor(
    private activatedRoute: ActivatedRoute,
    private nzMessageService: NzMessageService,
    private router: Router,
    private changeDetectorRef: ChangeDetectorRef
  ){}

  userLogin: boolean = false

  ngOnInit() {
    this.isLogin()
    this.changeDetectorRef.detectChanges()
  }

  cancel(): void {
    this.nzMessageService.info('取消推出');
  }

  confirm(): void {
    this.nzMessageService.info('确认退出');
    localStorage.removeItem('Token')
    localStorage.removeItem('customer')
    localStorage.removeItem('customerId')
    localStorage.removeItem('customerNickName')
    this.isLogin()
    this.router.navigate(['/home'])
  }

  isLogin() {
    if(!localStorage.getItem('Token')){
      this.userLogin = false
    } else {
      this.userLogin = true
    }
  }

}
